package com.indigon.parkStory.view.objects
{
	import com.indigon.parkStory.model.objects.WaveModel;
	
	import flash.display.DisplayObjectContainer;

	public class WaveView extends ObjectView
	{
		public function WaveView(wave:WaveModel)
		{
			super(new GFX_Wave(), wave);
		}
		
		public override function set(container:DisplayObjectContainer, x:Number, y:Number, rotation:Number=0, layer:uint=0):void
		{
			var wave : WaveModel = WaveModel(_object);
			graphic.width = graphic.height = wave.radius * 2;
			super.set(container, x, y, Math.random() * 360, 0);
		}
		
		public override function update():void
		{
			var wave : WaveModel = WaveModel(_object);
				
			if (wave.isDead)
			{
				uninit();
			}
			else
			{
				graphic.alpha = wave.value;
				graphic.rotation = 0;
				graphic.width = graphic.height = wave.radius * 2;
			}
		}
	}
}